/**
 * Created by Administrator on 2017/5/22.
 */

module.exports = function (sequelize, DataTypes) {
    var _model = sequelize.define("project", {
        projectid: {type: DataTypes.UUID, primaryKey: true, comment: '项目ID'}
        ,
        teamid: {
            type:DataTypes.STRING(100), comment: '团队ID', references: {
                model: sequelize.models.team
                , key:'teamid'
            }
        }
        , progress: {type: DataTypes.STRING(150), comment: '任务进度'}
        , title: {type: DataTypes.STRING(50), allowNull: false, comment: '职位名称'}
        , wiki: {type: DataTypes.STRING(150), comment: '接口协议'}
        , need: {type: DataTypes.STRING(150), comment: '项目问题'}
        , noteList: {type: DataTypes.TEXT("long"), allowNull: false,defaultValue:"", comment: '笔记目录'}
        , ext: {type: DataTypes.TEXT("long"), comment: '扩展字段'}
    }, {
        indexes: [ {
            name: 'projectid'
            , fields: ['projectid']
        }, {
            name: 'teamid'
            , fields: ['teamid']
        }]
        , classMethods: {
            associate: function (models) {
                _model.belongsTo(models.team, {foreignKey: 'teamid'});
            }
        }
    });
    return _model;
};